package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.common.Result;
import com.amsp.oa.oademo.entity.GongzuobxhpbEntity;
import com.amsp.oa.oademo.service.GongzuobxhpbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "工作表现评核表管理")
@RestController
@RequestMapping("/api/gongzuobxhpb")
public class GongzuobxhpbController {
    @Autowired
    private GongzuobxhpbService gongzuobxhpbService;

    @ApiOperation("分页查询工作表现评核表")
    @GetMapping("/getPage")
    public Result getPage(
            @ApiParam("页码") @RequestParam(defaultValue = "1") Long page,
            @ApiParam("每页记录数") @RequestParam(defaultValue = "10") Long limit,
            @ApiParam("工号") @RequestParam(required = false) String employeeId,
            @ApiParam("姓名") @RequestParam(required = false) String name,
            @ApiParam("部门") @RequestParam(required = false) String department) {
        return Result.ok(gongzuobxhpbService.queryPage(page, limit, employeeId, name, department));
    }

    @ApiOperation("获取工作表现评核表详情")
    @GetMapping("/getInfo/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return Result.ok(gongzuobxhpbService.getById(id));
    }

    @ApiOperation("批量保存或更新工作表现评核表")
    @PostMapping("/batchSaveOrUpdate")
    public Result batchSaveOrUpdate(@RequestBody List<GongzuobxhpbEntity> voList) {
        gongzuobxhpbService.saveOrUpdateBatch(voList);
        return Result.ok();
    }

    @ApiOperation("保存或修改工作表现评核表")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody GongzuobxhpbEntity voList) {
        gongzuobxhpbService.saveOrUpdate(voList);
        return Result.ok();
    }

    @ApiOperation("修改工作表现评核表")
    @PutMapping("/update")
    public Result update(@RequestBody GongzuobxhpbEntity gongzuobxhpb) {
        gongzuobxhpbService.updateById(gongzuobxhpb);
        return Result.ok();
    }

    @ApiOperation("删除工作表现评核表")
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable("id") Long id) {
        gongzuobxhpbService.removeById(id);
        return Result.ok();
    }

    @ApiOperation("删除工作表现评核表")
    @PostMapping("/batchRemove/{id}")
    public Result batchRemove(@RequestBody List<Long> ids) {
        gongzuobxhpbService.removeBatchByIds(ids);
        return Result.ok();
    }
}